package e.odbo.data.dao.table;

import com.openbravo.data.loader.serialize.serializer.SerializerRead;
import com.openbravo.data.loader.serialize.serializer.SerializerWrite;
import e.odbo.data.dsl.query.QBFParameter;
import e.odbo.data.dsl.query.QBFParameters;
import com.openbravo.data.loader.sentence.SentenceExec;
import com.openbravo.data.loader.sentence.SentenceFind;
import com.openbravo.data.loader.sentence.SentenceList;
import e.odbo.data.dao.I_ParentNode;
import e.odbo.data.dsl.operation.QueryOperation;
import e.odbo.data.dsl.Select;

import java.util.Date;

public class TableSentenceBuilderWarp {
    private TableDefinition table;
    private I_TableSentenceBuilder builder;

    public TableSentenceBuilderWarp(TableDefinition table, I_TableSentenceBuilder builder) {
        this.table = table;
        this.builder = builder;
    }

    public static TableSentenceBuilderWarp getInstance(TableDefinition table, I_TableSentenceBuilder builder){
        return new TableSentenceBuilderWarp(table,builder);
    }

    public TableDefinition getTable(){
        return table;
    }

    public SentenceList getListSentence(){
        return builder.getListSentence(table);
    }

    public  SentenceList getListSentence(SerializerRead sr){
        return builder.getListSentence(table,sr);
    }

    public  SentenceList getListSentence(SerializerRead sr,int[] fieldIndexs){
        return builder.getListSentence(table,sr,fieldIndexs);
    }

    public  SentenceList getListWithTimeSentence(SerializerRead sr,Date start, Date end){
        return builder.getListWithTimeSentence(table,sr,start,end);
    }

    public SentenceList getLisBySelectSentence(Select select, SerializerRead sr){
        return builder.getLisBySelectSentence(select,sr);
    }

    public SentenceFind getFindSentence(){
        return builder.getFindSentence(table);
    }

    public  SentenceFind getFindSentence(SerializerRead sr){
        return builder.getFindSentence(table,sr);
    }

    public  SentenceFind getFindSentence(SerializerRead sr, SerializerWrite sw){
        return builder.getFindSentence(table,sr,sw);
    }

    public  SentenceFind getFindSentence(SerializerRead sr, SerializerWrite sw,int[] fieldIndexs){
        return builder.getFindSentence(table,sr,sw,fieldIndexs);
    }

    public SentenceExec getDeleteSentence(){
        return builder.getDeleteSentence(table);
    }

    public  SentenceExec getDeleteSentence(SerializerWrite sw){
        return builder.getDeleteSentence(table,sw);
    }

    public  SentenceExec getClearSentence(){
        return builder.getClearSentence(table);
    }

    public  SentenceExec getInsertSentence(){
        return builder.getInsertSentence(table);
    }

    public  SentenceExec getInsertSentence(int[] fieldindx){
        return builder.getInsertSentence(table,fieldindx);
    }

    public  SentenceExec getInsertSentence(SerializerWrite objWrite){
        return builder.getInsertSentence(table,objWrite);
    }

    public  SentenceFind getFindByFieldIndexSentence(int index){
        return builder.getFindByFieldIndexSentence(table,index);
    }

    public  SentenceExec getCountSentence(){
        return builder.getCountSentence(table);
    }

    public  SentenceFind getCountSentence(QBFParameters filter){
        return builder.getCountSentence(table,filter);
    }

    public  SentenceFind getExistSentence(SerializerWrite rowWriter){
        return builder.getExistSentence(table,rowWriter);
    }

    public  SentenceFind getExistSentence(String[] fields){
        return builder.getExistSentence(table,fields);
    }

    public  SentenceExec getUpdateSentence(){
        return builder.getUpdateSentence(table);
    }

    public  SentenceExec getUpdateSentence(int[] fieldIndex){
        return builder.getUpdateSentence(table,fieldIndex);
    }

    public  SentenceExec getUpdateSentence(int[] fieldIndex, SerializerWrite rowWriter){
        return builder.getUpdateSentence(table,fieldIndex,rowWriter);
    }

    public  SentenceExec getUpdateSentence(SerializerWrite rowWriter){
        return builder.getUpdateSentence(table,rowWriter);
    }

    public SentenceList getQuerySentence(QBFParameters filter,SerializerRead sr){
        return builder.getQuerySentence(table,filter,sr);
    }

    public SentenceExec getDeleteSentence(QBFParameters filter){
        return builder.getDeleteSentence(table,filter);
    }

    public SentenceFind getCountSentence(QBFParameter filter){
        return builder.getCountSentence(table,filter);
    }

    public SentenceList getListByParentSentence(I_ParentNode parent,Class realParentClass,SerializerRead sr) {
        return builder.getListByParentSentence(table, parent,realParentClass,sr);
    }

    //list QueryOperation

    public SentenceList getListSentence(QueryOperation queryOperation){
        return builder.getListSentence(table,queryOperation);
    }

    public SentenceList getListSentence(SerializerRead sr,QueryOperation queryOperation){
        return builder.getListSentence(table,sr,queryOperation);
    }

    public SentenceList getListSentence(SerializerRead sr,int[] fieldIndexs,QueryOperation queryOperation){
        return builder.getListSentence(table,sr,fieldIndexs,queryOperation);
    }

    public SentenceList getListWithTimeSentence(SerializerRead sr, Date start, Date end,QueryOperation queryOperation){
        return builder.getListWithTimeSentence(table,sr,start,end,queryOperation);
    }

    public SentenceList getListByParentSentence(I_ParentNode parent,Class realParentClass,SerializerRead sr,QueryOperation queryOperation){
        return builder.getListByParentSentence(table,parent,realParentClass,sr,queryOperation);
    }


    public SentenceList getQuerySentence(QBFParameters filter,SerializerRead sr,QueryOperation queryOperation){
        return builder.getQuerySentence(table,filter,sr,queryOperation);
    }

    public SentenceList getQuerySentence(SerializerRead sr,int[] fieldIndexs,QBFParameters filter){
        return builder.getQuerySentence(table,fieldIndexs,filter,sr);
    }

    public SentenceList getQuerySentence(SerializerRead sr,int[] fieldIndexs,QBFParameters filter,QueryOperation queryOperation){
        return builder.getQuerySentence(table,fieldIndexs,filter,sr,queryOperation);
    }

    public I_TableSentenceBuilder getBuilder(){
        return this.builder;
    }
}
